package com.example.multilpeDataSource.service;

import com.example.multilpeDataSource.config.DataSources;
import com.example.multilpeDataSource.config.RoutingDataSource;
import com.example.multilpeDataSource.dao.UserMapper;
import com.example.multilpeDataSource.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

/**
 * @author wangzhendong
 * @data 2020-02-08 14:10
 */
@Service
@Component
public class UserService {

    @Autowired
    private UserMapper userMapper;

    @RoutingDataSource(value = DataSources.SLAVE_DB)
    public User findById(Integer id){
        return userMapper.findById(id);
    }

    @RoutingDataSource(value = DataSources.SLAVE_DB)
    public Integer add(Integer id, String name){
        return userMapper.add(id, name);
    }

   
    public Integer add1(Integer id, String name){
        return userMapper.add(id, name);
    }
}
